import '@/App.scss'
// 导入路由
import { Router, Route, Switch, Redirect } from 'react-router-dom'
import PrivateRoute from '@/components/PrivateRoute'
import history from './utils/history'
import KeepAlive from './components/KeepAlive'

// 导入页面组件
import Login from '@/pages/Login'
import Layout from '@/pages/Layout'
import ProfileEdit from '@/pages/Profile/Edit'
import Chat from '@/pages/Profile/Chat'
import Article from '@/pages/Article'
import Search from '@/pages/Search'
import SearchResult from '@/pages/Search/Result'

function App() {
  return (
    <Router history={history}>
      <div className="app">
        <KeepAlive activePath="/home" path="/home">
          <Layout></Layout>
        </KeepAlive>
        <Switch>
          <Route exact path="/" render={() => <Redirect to="/home" />} />
          <Route path="/login">
            <Login />
          </Route>
          <PrivateRoute path="/profile/edit">
            <ProfileEdit />
          </PrivateRoute>
          <PrivateRoute path="/chat">
            <Chat />
          </PrivateRoute>
          <Route path="/article/:id">
            <Article></Article>
          </Route>
          <Route exact path="/search">
            <Search></Search>
          </Route>
          <Route exact path="/search/result">
            <SearchResult></SearchResult>
          </Route>
        </Switch>
      </div>
    </Router>
  )
}

export default App